package main

import (
	"craft/core"
	"craft/core/ast"
	"fmt"
)

func main() {
	l := core.LexicalAnalyzer{}
	c := core.Calculator{}
	_script := "int age = a+2"
	_tokens := l.Analyze(_script)
	_astNode, _err := c.IntDeclare(&_tokens)
	if _err != nil {
		fmt.Println(_err)
	} else {
		fmt.Println(ast.Dump(*_astNode, 0))
	}

	_script = "23+45/45*100+245"
	_tokens = l.Analyze(_script)
	_astNode, _err = c.Additive(&_tokens)
	if _err != nil {
		fmt.Println(_err)
	} else {
		fmt.Println(ast.Dump(*_astNode, 0))
		fmt.Println(c.Evaluate(*_astNode, "|"))
	}

	_script = "23+"
	_tokens = l.Analyze(_script)
	_astNode, _err = c.Additive(&_tokens)
	if _err != nil {
		fmt.Println(_err)
	} else {
		fmt.Println(ast.Dump(*_astNode, 0))
		fmt.Println(c.Evaluate(*_astNode, "|"))
	}
}
